package io.netty.client.Bio;

import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;

public class SocketServer {
    /**
     * bio实现服务器端
     * 1，单个线程
     * 2，多个线程
     * 3，线程池
     */
    public static void main(String[] args) throws IOException {
        ServerSocket serverSocket = new ServerSocket(8989);
        while (true){
            Socket accept = serverSocket.accept();
            handler(accept);
        }
    }

    public static  void handler(Socket socketClient) throws IOException {
        byte[] bytes = new byte[2048];
        int read = socketClient.getInputStream().read(bytes);
        if (read != -1) {
            System.out.println("接收客户端消息"+new String(bytes,0,read));
        }
        System.out.println("一次读取完成");
    }


}
